//
//  GLRotationAnimation.cpp
//  Texture
//
//  Created by Yao Melo on 3/2/13.
//
//

#include "GLRotationAnimation.h"

GLRotationAnimation::GLRotationAnimation(double duration,Vec3 axis,float startAngle, float endAngle):GLAnimation(duration),_axis(axis),_startAngle(startAngle), _endAngle(endAngle)
{
    
}

GLRotationAnimation::~GLRotationAnimation(){}

void GLRotationAnimation::GetTransformTemplate(MATRIX& mOut, double timestamp)
{
    float currAngle;
    if(timestamp < _start)
    {
        currAngle = _startAngle;
    }
    else if(timestamp - _start > _duration)
    {
        currAngle = _endAngle;
    }
    else
    {
        currAngle = _startAngle + ((_endAngle - _startAngle)* (timestamp - _start)/_duration);
    }
    MatrixRotationAxis(mOut, currAngle, _axis.x, _axis.y, _axis.z);
    
}